package com.mayuanfei.service.impl;

import cn.hutool.core.util.IdUtil;
import com.aizuda.snailjob.client.core.IdempotentIdGenerate;
import com.aizuda.snailjob.common.core.model.IdempotentIdContext;
import com.google.common.hash.Hashing;

import java.nio.charset.StandardCharsets;

/**
 * TODO 类描述
 *
 * @author 老马
 * @date 2025-04-18 13:35
 */
public class MyIdempotentId implements IdempotentIdGenerate {
    @Override
    public String idGenerate(IdempotentIdContext context) throws Exception {
        String str = context.toString() + IdUtil.fastSimpleUUID();
        return Hashing.md5().hashBytes(str.getBytes(StandardCharsets.UTF_8)).toString();
    }
}